﻿<?php 
   /**
   * 竞赛结果表
   *存放竞赛等级情况
   *@author kinet 380511703@qq.cn
   *@time 2010-4-18 to 2010-4-23    
   *@version 1.2
   */
  require_once('db_obj.class.php') ; 
  class contest_team extends db_obj{
      
          private $vdb;      
          public function __construct( $db ){
      
                 parent::__construct( $db , 'contest_team' );
                 $this->vdb=$db;    
                 $this->add('contest_no' , '');                  
                 $this->add('team_no' , '');
                 $this->add('rightnum',0); 
                 $this->add('timeuse',0); 
        }
        /**
        * 用于判断是否队伍属于竞赛
        * 载入竞赛
        * 
        * @param 竞赛号
        * @param 队伍号
        */
        public function load($contest_no,$team_no){
               $res = $this->vdb->query( "SELECT * FROM contest_team
                                              WHERE team_no=".$team_no." 
                                                        and
                                                    contest_no=".$contest_no ); 
                  if ( !$res ){
                        return false ;
                  }
                  if($rows = $res->fetchRow( MDB2_FETCHMODE_ASSOC )){
                      $this->set('team_no',$team_no);
                      $this->set('contest_no',$contest_no);
                       $this->set('rightnum',$rows['rightnum']);       
                      $this->set('timeuse',$rows['timeuse']);
                      return true;                      
                  }
                  else 
                      return false;
            
        }
        public function update(){
            $sql="update contest_team 
                  set rightnum=".$this->get('rightnum').",
                  timeuse=".$this->get('timeuse')."
                  where 
                  team_no=".$this->get('team_no')."
                  and 
                  contest_no=".$this->get('contest_no');  
            $this->vdb->query( $sql );   
           
        }
        public function del(){
            $this->vdb->query( "DELETE FROM contest_team 
                                WHERE contest_no =".$this->get('contest_no')." 
                                     and
                                     team_no=".$this->get('team_no') );  
            
        }    
            
       

    } 
   
?>
